<template>
  <div class="container">
    <div class="header">
      <span>编辑消息</span>
      <el-button @click="comfirm">确认</el-button>
    </div>    
    <div class="bottom">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="消息标题" prop="msg_title" >
          <el-input v-model="ruleForm.msg_title" style="width:467px; height: 36px"></el-input>
        </el-form-item>
        <el-form-item label="消息类型" prop="msg_type">
          <el-select v-model="ruleForm.msg_type" placeholder="请选择消息类型" style="width:467px; height: 36px">
            <el-option label="系统消息" value="1"></el-option>
            <el-option label="订单消息" value="2"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="消息内容" prop="msg_content">
          <el-input type="textarea" v-model="ruleForm.msg_content" placeholder="请输入消息内容" class="message-content"></el-input>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import {addMessage} from '@/api/operation'
import {ERR_OK} from '@/api/config'
export default {
  data() {
    return{
      ruleForm: {
        msg_title: '',
        msg_type: '',
        msg_content: '',
      },
      rules: {
        title: [{ required: true, message: '请输入消息标题', trigger: 'blur' }],
        type: [{required: true, message: '请输入消息类型', trigger: 'blur'}],
        content: [{required: true, message: '请输入消息内容', trigger: 'blur'}],
      }
    }
  },
  methods: {
    comfirm() {
      this.$router.push({path: '/platform/messageInform'})
      addMessage(this.ruleForm)
        .then((res) => {
          if (res.code == ERR_OK) {
            console.log(res)
          } 
        })
        .catch((err) => {
          console.log(err)
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.container{
  padding: 20px;
  padding-top: 60px;
}
.header{
  width: 100%;
  height: 80px;
  display: flex;
  justify-content: space-between;
  .el-button{
    width: 87px;
    height: 30px;
    line-height: 20px;
    border-radius: 6px;
    background-color: rgba(27, 166, 135, 1);
    text-align: center;
    padding: 0;
    color: #fff;
  }
}
.message-content /deep/ .el-textarea__inner{
  width: 467px;
  height: 318px;
}
</style>